import cv2
import numpy as np


def scanQrcode(image_path):
    path = "opencv_3rdparty-wechat_qrcode"

    detector = cv2.wechat_qrcode_WeChatQRCode(path + "detect.prototxt", path + "detect.caffemodel",
                                              path + "sr.prototxt", path + "sr.caffemodel")
    img = cv2.imread(image_path)
    res, points = detector.detectAndDecode(img)

    cv2.drawContours(img, [np.int32(points)], 0, (0, 0, 255), 2)

    print(res, points)
    cv2.imshow('img', img)
    cv2.waitKey(0)


if __name__ == '__main__':
    image_path = "test1111.png"
    scanQrcode(image_path)
